public class Test {

    public static void main(String[] args) {
        String s = "abcd";
        StringBuilder stringBuilder1 = new StringBuilder("abcd");
        StringBuilder stringBuilder = new StringBuilder(s);
        stringBuilder.append(stringBuilder1);
        StringBuffer stringBuffer = new StringBuffer();
        System.out.println();
    }
    public static void main4(String[] args) {
        StringBuilder stringBuilder = new StringBuilder("hello");
        System.out.println(stringBuilder.reverse());
    }

    public static void main2(String[] args) {
        StringBuilder stringBuilder1 = new StringBuilder("hello");
        System.out.println(stringBuilder1);

        //String s = stringBuilder1;//err string和stringbuilder是两个不同类
        String s = stringBuilder1.toString();//返回一个新字符串
        System.out.println(s);
    }


    public static void main1(String[] args) {
        String str = "abcd";
        for (int i = 0; i < 100; i++) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(str);
            stringBuilder.append(i);
            str = stringBuilder.toString();
        }
        System.out.println(str);

        String str1 = "abcd";
        for (int i = 0; i < 100; i++) {
            str1 += i;
        }
        System.out.println(str);
    }
    //StringBuilder stringBuilder = "hello";  err StrigBuilder类不能直接赋值
    StringBuilder stringBuilder = new StringBuilder(23); //创建一个字符数组大小为23，赋值为默认值

}
